//    Copyright (C) 2010 by Dolphin Thnology
//    All rights reserved.
// 
//    Copyright Notification
//    No part may be reproduced except as authorized by written permission
// 
//    @file   dti_counter.v
//    @par    Company:
//              Dolphin Technology
//    @par    Project:
//              [projectname]
//    @par    Author:
//              N. Huy Bui
//    @par    Date:
//              July 17, 2012
//    @brieft
//              Counter for [dti_asym_outbuf] module
//$Id$

module dti_counter (pop_clk, pop_rst_n, pop_req_n, fifo_empty, count_out);

//parameters declaration
parameter 	  IN_WIDTH    = 24;
parameter 	  OUT_WIDTH   = 8;
parameter 	  BYTE_ORDER  = 0;
parameter 	  K 	      = IN_WIDTH/OUT_WIDTH;
parameter 	  COUNT_WIDTH = $clog2 (K);

//IOs declaration
input 		  pop_clk;
input 		  pop_rst_n;
input 		  pop_req_n; 			//pop request, active low
input 		  fifo_empty;
output wire [COUNT_WIDTH-1:0] count_out;

generate 
  if (BYTE_ORDER)
    dti_up_counter #(IN_WIDTH, OUT_WIDTH)
      dti_counter_inst (pop_clk, pop_rst_n, pop_req_n, fifo_empty, count_out);
  else
    dti_down_counter #(IN_WIDTH, OUT_WIDTH)
      dti_counter_inst (pop_clk, pop_rst_n, pop_req_n, fifo_empty, count_out);
endgenerate

endmodule // dti_counter
